package com.hectopascal.goalance.service;

import com.hectopascal.goalance.pojo.Target;
import com.hectopascal.goalance.repository.TargetRepository;
import com.hectopascal.goalance.service.Ipml.ITargetService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class TargetService implements ITargetService {
    @Autowired
    TargetRepository targetRepository;

    @Override
    public Target targetAdd(Target target) {
        return targetRepository.save(target);
    }

    @Override
    public List<Target> targetGet(Integer userId) {
        return targetRepository.findTargerById(userId).get();
    }

    @Override
    public int targetUpdate(Target target) {
        return targetRepository.updateTarget(target.getName(),target.getDescription(),target.getProgress(),target.getDeadline(),target.getId());
    }
}
